package com.supply.dl.utils.utils;

import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.widget.Toast;

public class ToastUtil {

    public final static boolean DEBUG = false;

    public static void showToast(final Context context, final String s) {
        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                Toast.makeText(context, s, Toast.LENGTH_SHORT).show();
            }
        };
        if (Looper.myLooper() == Looper.getMainLooper()) {
            runnable.run();
        } else {
            new Handler().post(runnable);
        }
    }

    /**
     * 调试Toast
     * @param context
     * @param s
     */
    public static void debugToast(Context context, String s) {
        if (DEBUG) {
            showToast(context, s);
        }
    }
}
